/**
 * This file is part of 1genia trampoline
 * Copyright (C) 2007 1genia (contact@1genia.com)
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; version 3 of the License.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; see the file COPYING.TXT.  If not,
 * write to the Free Software Foundation, Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301, USA.
 **/
package com.genia.toolbox.config.autoconfiguration.bean;

import java.io.File;

import org.apache.commons.lang.RandomStringUtils;

/**
 * The bean keeping the configuration.
 */
public class ConfigurationBean {

	/**
	 * the default password needed to change the configuration.
	 */
	public static final String DEFAULT_PASSWORD = "password";

	/**
	 * the default encrypted status of the password.
	 */
	public static final Boolean DEFAULT_ENCRYPTED = Boolean.FALSE;

	/**
	 * the default size of the pool for resources.
	 */
	public static final int DEFAULT_POOL_MAX_SIZE = 10;

	/**
	 * the default active status of the Web Service Interceptor.
	 */
	public static final Boolean DEFAULT_WS_INTERCEPTOR_ACTIVE = Boolean.FALSE;

	/**
	 * the default active status of the Web Service Interceptor.
	 */
	public static final Boolean DEFAULT_SUPRESS_READ_ONLY_TRANSACTIONS = Boolean.FALSE;

	/**
	 * the password needed to change the configuration.
	 */
	private String password = DEFAULT_PASSWORD;

	/**
	 * the encrypted status of the password.
	 */
	private Boolean encrypted = DEFAULT_ENCRYPTED;

	/**
	 * the size of the pool for resources.
	 */
	private int poolMaxSize = DEFAULT_POOL_MAX_SIZE;

	/**
	 * the active status of the web service Interceptor.
	 */
	private Boolean wsInterceptorActive = DEFAULT_WS_INTERCEPTOR_ACTIVE;

	/**
	 * the active status of the web service Interceptor.
	 */
	private Boolean supressReadOnlyTransactions = DEFAULT_SUPRESS_READ_ONLY_TRANSACTIONS;
	
	private String hibernateSessionFactoryProperties = "";

	/**
	 * the configuration of the database.
	 */
	private DatabaseConfigurationBean databaseConfigurationBean = new DatabaseConfigurationBean();

	/**
	 * the configuration of the mail.
	 */
	private MailConfigurationBean mailConfigurationBean = new MailConfigurationBean();

	/**
	 * the directory containing the configuration and used as a base for all
	 * generated files of the application that must go in the filesystem.
	 */
	private File configurationDirectory;

	/**
	 * the nounce to use.
	 */
	private String nounce = null;

	/**
	 * getter for the databaseConfigurationBean property.
	 * 
	 * @return the databaseConfigurationBean
	 */
	public DatabaseConfigurationBean getDatabaseConfigurationBean() {
		return databaseConfigurationBean;
	}

	/**
	 * setter for the databaseConfigurationBean property.
	 * 
	 * @param databaseConfigurationBean
	 *            the databaseConfigurationBean to set
	 */
	public void setDatabaseConfigurationBean(
			DatabaseConfigurationBean databaseConfigurationBean) {
		this.databaseConfigurationBean = databaseConfigurationBean;
	}

	/**
	 * getter for the mailConfigurationBean property.
	 * 
	 * @return the mailConfigurationBean
	 */
	public MailConfigurationBean getMailConfigurationBean() {
		return mailConfigurationBean;
	}

	/**
	 * setter for the mailConfigurationBean property.
	 * 
	 * @param mailConfigurationBean
	 *            the mailConfigurationBean to set
	 */
	public void setMailConfigurationBean(
			MailConfigurationBean mailConfigurationBean) {
		this.mailConfigurationBean = mailConfigurationBean;
	}

	/**
	 * getter for the configurationDirectory property.
	 * 
	 * @return the configurationDirectory
	 */
	public File getConfigurationDirectory() {
		return configurationDirectory;
	}

	/**
	 * setter for the configurationDirectory property.
	 * 
	 * @param configurationDirectory
	 *            the configurationDirectory to set
	 */
	public void setConfigurationDirectory(File configurationDirectory) {
		this.configurationDirectory = configurationDirectory;
	}

	/**
	 * getter for the password property.
	 * 
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * setter for the password property.
	 * 
	 * @param password
	 *            the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * getter for the poolMaxSize property.
	 * 
	 * @return the poolMaxSize
	 */
	public int getPoolMaxSize() {
		return poolMaxSize;
	}

	/**
	 * setter for the poolMaxSize property.
	 * 
	 * @param poolMaxSize
	 *            the poolMaxSize to set
	 */
	public void setPoolMaxSize(int poolMaxSize) {
		this.poolMaxSize = poolMaxSize;
	}

	/**
	 * getter for the nounce property.
	 * 
	 * @return the nounce
	 */
	public String getNounce() {
		if (nounce == null) {
			nounce = RandomStringUtils.randomAlphanumeric(12);
		}
		return nounce;
	}

	/**
	 * setter for the nounce property.
	 * 
	 * @param nounce
	 *            the nounce to set
	 */
	public void setNounce(String nounce) {
		this.nounce = nounce;
	}

	/**
	 * getter for the wsInterceptorActive property.
	 * 
	 * @return the nounce
	 */
	public Boolean getWsInterceptorActive() {
		return wsInterceptorActive;
	}

	/**
	 * setter for the wsInterceptorActive property.
	 * 
	 * @return the nounce
	 */
	public void setWsInterceptorActive(Boolean wsInterceptorActive) {
		this.wsInterceptorActive = wsInterceptorActive;
	}

	public Boolean getSupressReadOnlyTransactions() {
		return supressReadOnlyTransactions;
	}

	public void setSupressReadOnlyTransactions(
			Boolean supressReadOnlyTransactions) {
		this.supressReadOnlyTransactions = supressReadOnlyTransactions;
	}

	public String getHibernateSessionFactoryProperties() {
		return hibernateSessionFactoryProperties;
	}

	public void setHibernateSessionFactoryProperties(
			String hibernateSessionFactoryProperties) {
		this.hibernateSessionFactoryProperties = hibernateSessionFactoryProperties;
	}
}
